package com.example.springbootquartz.mapper;

import com.example.springbootquartz.bean.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * @version 0.1
 * @auth admin.
 * @time 2018/5/27 16:32
 * @since 0.1
 */
@Mapper
public interface UserMapper {

    @Select("SELECT * FROM USERS T WHERE T.ID = #{id}")
    User queryUserById(long id);

    @Select("SELECT id,uid,psw,modify_time as modifyTime, create_time as createTime, state FROM USERS LIMIT 1")
    User queryUserLimitFirst();

    @Insert("INSERT INTO USERS (id,uid,psw,modify_time,create_time,state) " +
            "VALUES (#{id},#{uid},#{psw},#{modifyTime},#{createTime},#{state})")
    void insertUser(User user);

    @Update("UPDATE USERS T SET " +
            "uid = #{uid}, psw = #{psw}, modify_time = #{modifyTime},create_time = #{createTime}, state = #{state} " +
            "WHERE id = #{id}")
    void updateUserById(User user);
}
